HEAD formatting and minor bug fixes