Various code refactorings
|Reported by:||rjollos||Owned by:||rjollos|
|Cc:||hasienda, cbalan||Trac Release:|
I've spotted a number of issues with the code during review. The changes will be committed individually against this ticket. Please review and comment on any issue you see, if you can.