cleaned up the source a little  (unfinished)