Removed unnecessary printing statements; Added functionality for both range and before statement; cleaned up a little bit of the code, still ugly the way it sits however.