fixing some long suffering bugs