Fixed some minor bugs - Cleaned source code