track memory usage
misc fixes