serious code clean up