Reorganized code. Getting all bugs.