Cleaned up code. Added time structure