many big changes in this commit