Fixed paging and nil ref errors. Removed debugging code.