Added some new support functions
Removed some old/hacky code