Fixed Bugs in Code

Fixed the errors that were general in the code.