Smoothing, data cutting, comments, new functions

Converted code to functions for easier library access. Modified
smoothing algorithm and added better comments. Smoothing has some bugs
though.