tidy up compile, add back detect