General code clean up and start using some immutable collections in the code.