Code cleanup
Error handling & code debug