Refactored the sd stuff to accept parameter array instead of bunch of arguments.