Fixed issue #5. Partially fixed issue #1.