Refactor some internal APIs
Remove some more compiler warnings
PLCBC-3: Check harder to ensure element is not an arrayref