Fix strict warning, minor performance improvement

array_pop() requires a reference and throws a STRICT warning otherwise;
also, end() should be faster since we don't need to modify it