Bug & warning fixes