Fixed bugs and changed formatting