Stability fixes

-Fixed a number of stability and lock issues.
-Cleaned up old code

Signed-off-by: Bennie Leonard <bennie.leonard@gmail.com>
Merge pull request #13 from benniel/fixes

Stability fixes