Fixed issues and restored original functionality