cleanup alot of legacy code. find the bugs!