Tidy up the API builder class and auto discover output directory