Make BEGIN/END optional in the API; fix #138