Refactor part where we check for checked kings. For #7.
Refactoring part where we set the castle flags. For #7.
Remove unused boolean variable. For #7.