Change some signatures
Add type declarations to standalone functions