fixes and code reduction.