Correct use of mainqueue and build optimise.