fixed type casts for database saving and selecting (arrays fully supported now)