Final version w/o debug and comments standardized.