fixes and code clean up