Merge pull request #1 from ShaneGH/master

Bug fixing and profiling
Merge pull request #2 from ShaneGH/master

Mostly bug fixes