Added some flags and more logging statements