Fixed several bugs and now functional