make build work outside of gilt
cleanup code a bit