Fix all errors and bugs, improve code quality