Style and bug fixes