bugfix, code cleanup

Fixed error when compiler ends up with error and source map generation
crashes whole process. Also did some code cleanup for better docs.