Removed the sigmoid and sigmoid gradient subfunctions to separate functions.