Add time support and more cleanup, still lots of debugging code