code cleaning, optimizations + customizable delay