bugfix in source maps code and some cleanup

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