Refactor, get more things working