Main code rev. 1726

Code cleanup of ternary conditions and removed trailing spaces.