Bug fixes.

Resolves #272 #233 #276