various bug fixes

closes #56,
closes #53,
closes #51,
closes #48,
closes #47,
closes #46,
closes #41,
closes #11,
closes #10