Fixes and improvements according to supervisor's suggestions.