Fixed some formatting issues and bug