Free memory
input normalization
Added documentation