Updated with std.dev, commenting, etc.