Added auto-create directories, fixed minor bugs

Directories are now more clearly defined at the top of the file. And
added directory auto-create to avoid crashes and speed up the
installation process (compile+run is all that's required now)

Fixed a small bug with the line number variable being initialised wrong.

Added check for the MAX_REMOVED_OBJECTS constant to ensure this value
isn't exceeded.