fixed boot bug, and refactored