Added optional frame parameter to all analysis functions.Added some more comments.