small code changes and some cleanup