Greatest part of the work done. Still some bugs to fix