Add build protection and re-format code