pages handler and tool refactoring, some bug fixes