Bug Fixes and Code Formatting