refactor pretty much everything so that it actually works...