various changes after some testing and fixing