implemented page flushing and made minor tweaks