fixed typeof appearances. some more cleanup.