various code cleaned up