Bugfix

Fix bug that NPE was thrown when castled
Revert "Bugfix"

This reverts commit 5d2ba2948c8a0c70a3c3227085b439bd8f2775f5.
Revert "Revert "Bugfix""

This reverts commit 316e0f11b9d2639b65b691ad9b2127e3df2e5999.