Tested code commented.