WIP: Fixed some bugs, almost ready
Still some TODOs, but basic functionality is there