Refactored mlp.py