Added better end of function detection
Cleaned up build directory