Bugfixes and improvements

Added flag defaults
Merge remote-tracking branch 'upstream/master'