style and bug fixes