Fixed bugs and formatting issues