Updating to 1.8, code cleanup and optimize. part 1