WIP: More testing needed, fix several bugs and errors.

Issue #3
Issue #4