Add type signatures, minor tweaks