Debugged and bugfixed