put everything together, clean up, optimized some parameters