Port low level

Most important functions added & working
Use references instead of pointers.