Preliminary refactoring of code to best practices.
Further refactoring/reformatting via ReSharper.