small bug fixes + restructure

close issue #3