Fixed some issues and bugs in the code. Application works now.