Many fixes and stylistic changes