Fixed various type errors, closing issue #6