Reorder functions
Rewrite net code to something more useful