fixed build file creation if none exist, further refactoring