Implemented casts and new-style patterns
Modified select/replace and removed retrieve