major code clean-up