modded signature for append_to_moving_avg, implemented free_moving_avg

Now returning ints with error codes.
Added a ton of error checking, and edge-case checking.

Cleaned up stuff into a secondary method, and moved things... along.
Added a macro that checks for nullity of arguments.
Removed some comments that weren't adding anything.