General code fixes and updates

General code fixes and updates