Add `@nogc` to digest algorithms

Also I added `@safe` where possible, and moved attributes after parameters.