Added more type signatures.  Refactoring.