Rebuilding logic, simple paging is worked (WARNING: not fully ready yet)