Added pytables code. Looks much cleaner now.