Style fixes and bug fixes