Tidied up comments and some code; also fixed an error where count increments one too much for initial insertion to a table element.