Fixed minor bugs and improved formatting