Cleanup of table view controller

I implemented freeing of the popover by setting its delegate and freeing it on dismiss.

I also removed some unneeded stuff and organized things a bit.