Stability/integrity improvements

Implements fixes for issues #3, #4, and #2.
Ah, right. Will fix that.