modernize pica and some refactoring