Formatting and bug fixes