Added more type annotations to clean up type signatures of functions/values.