Fixed a whole bunch of errors, style improvements