Various small changes; need to fix free memory issues