Style improvements and bug fixes