Cleaned up code.
Merge branch 'master' into debug