Better design, fix bugs and code improvements