bugfixes for 385,260

code review:
http://mrccodereview.cloudapp.net/ui#review:id=1245