Refactored swnp.py