Clean and update build output more intelligently

Fixes #183.
please call getProject() once at the top of the method