actual build, fixed some problems, clean up code