Formatting and minor bug fixes