Refactored the Scanner class to improve its api.