cleanup and general improvement of source code