Needs some serious cleanup