Welcome to the community. You are very unlikely to get help if you post such a large amount of code and with such messy formatting. Try breaking the problem down into smaller pieces and ask for help on a concrete problem. In particular, provide a small code snippet that reproduces the error you get so that people can copy and paste it into their own REPL. See this topic