Fixed some bugs and indentation issues