Added sigmoid function and some clearing up