Use structured numpy array to hold results

Makes the code a bit cleaner. Also added some comments to the code.