Code clean up after huge mess