Formatting and some minor refactors