formatting and bug fixes