minor bug fixes and improvments

Same as #184 but without shared_ptr. (and based on soci:develop branch)