Latest modifications of profile script, various code improvements, comments, etc.