ending branch for restart

SVN-Revision: 40544
restart of branch, this is to include changes from trunk

SVN-Revision: 40545
merged fixes from previous instance of branch (r38875:40542), addressing #856 and #586

SVN-Revision: 40550
removed whitespace at the end of lines

SVN-Revision: 40552
formatted code: removed whitespace at end of lines and added some empty lines to increase readability

SVN-Revision: 40689
formatted code: added some empty lines to increase readability

SVN-Revision: 40690
removed compiler warning about missing newline at end of file

SVN-Revision: 40691
fixed signedness of variable and cleaned up whitespace

SVN-Revision: 40696
Test case and possible fix for Issue #1002

SVN-Revision: 40700