added several fixes