Formatting and implementation refactor