Integrate scanner and fix bugs