Code refactors to accomodate typescript's --no-implicit-any option

Code refactors to accomodate typescript's --no-implicit-any option
It is used in 16 places in the code. Given the huge impact of this PR I prefer to issue another one which removes it.