Import from previous code

Need unit tests