Make target attribute variable; write pickle file in cwd; some refactoring.