Some bug fixes; not entirely working correctly yet

Form should be essentially correct, though.