Removed unnecessary global lastPage variable. Prepared for having 4 plane types.