Fixed formatting and bugs