lots more changes, added functionality