First refractor and clean up of previous code. No new code was added