limit polution of global scope+minor fixes