Almost completely rewrite base on oop, mvc structure.