Cleaned up and removed some old code