Initial pull request

check memory usage. Also, free if password already allocated