Fixes in installation, added clean up of temporary files, minor refactoring.