Change errors array to Enum thing
Various cleanup and minor bugfixes