Code optimization

Changed a lot of code to increase compliance with Microsoft's Basic
Design Guidelines. There are still 172 issues to fix...