Cleaned up code, input is fen string.