fixed some memory leaks, added some auto layout