some bug fixes after testing with live data
Merge remote-tracking branch 'origin/master'