cleaned up castle.c