fixed a few issues, still not entirely working.