Various fixes (race conditions,bugs) and redundant types cleanup

Prefer the explicit syntax over the implicit type.