Minor modifications and code refactoring.