Array and functions cast fixes