Bug fixes - closes #12, #30