Added insert; Fixed end; Almost works

Added in the final test for inserting code, made it search for using the
end function for code before the final ?>, there only seems to be one
issue with end code resembling previous code parsing incorrectly.