code cleanup, minor improvements