Lots of changes, hope this doesn't break anything