added wrappers for env and txn, better exception throwing, fixed a few errors