Major changes

Might be slightly buggy but compiles :D