Fixed some variable declarations and exception messages