#491 bug fixes