Some code refactoring, minor fixes, more drawing