Fixed page offset in get_headers function and cleaned up some code.