major cleanup

Still bugs left, but will be fixed soon